package hcn.protocol.ods.report;

import com.fasterxml.jackson.annotation.JsonGetter;
import com.fasterxml.jackson.annotation.JsonIgnore;
import ctd.util.annotation.DicMapping;
import ctd.util.annotation.MappingType;
import ctd.util.xml.jaxb.DateTimeAdapter;

import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
import java.io.Serializable;
import java.util.Date;

/**
 * Created by jinxin on 2016/5/18.
 */
@XmlRootElement(name = "report")
public class ReportBean implements Serializable{
    private static final long serialVersionUID = -6550537551050286164L;

    @DicMapping(type = MappingType.BEAN)
    private PatientBean patient;
    private String orgId;               //云机构标识
    private String sourceId;            //院内唯一标识
    private String sourceFrom;          //数据来源
    private String crisisFlag;          //危机值标志
    private String crisisDesc;          //危机描述
    private String unusualFlag;         //异常值标志
    private String reportType;          //报告类型
    @DicMapping(dic = "reportSource&hcn-ods-dictionary-reportSource")
    private String reportSource;        //就诊类型  报告来源  00：未知 01：门诊 02：急诊 03：留观 04：住院 05：体检
    private String clinicNo;            //就诊号
    private InnerBean org;              //开单运机构标识
    private InnerBean dept;             //开单科室标识
    private InnerBean doctor;           //开单医生
    private Date createDt;              //报告开单时间
    private InnerBean rpOrg;            //报告运机构标识
    private InnerBean rpDoctor;         //报告医生
    private Date reportDt;              //报告时间
    private InnerBean checkDoctor;      //审核医生
    private Date checkDt;               //审核时间
    private String comment;             //备注
    private Date beginDate;             //开始时间
    private Date endDate;               //结束时间
    private String dealFlag = "0";      //处理标志
    private String needDealFlag = "0";  //需要处理标志
    private String dealMan;             //处理人
    private Date dealDt;                //处理时间
    private String dealOpinion;         //处理意见
    private String inpatientArea;       //病人病区

    //默认构造函数没有会报错
    public ReportBean() {
    }

    public ReportBean(PatientBean patient, String orgId, Date begin, Date end) {
        this.patient = patient;
        this.orgId = orgId;
        this.beginDate = begin;
        this.endDate = end;
    }

    @XmlElement(name = "patient")
    public PatientBean getPatient() {
        return patient;
    }

    public void setPatient(PatientBean patient) {
        this.patient = patient;
    }

    @XmlTransient
    public String getPatientName() {
        return patient != null ? patient.getPatientName() : null;
    }

    public String getOrgId() {
        return org != null ? org.getText() : orgId;
    }

    @XmlTransient
    public String getOrgName() {
        return org != null ? org.getLocalText() : null;
    }

    public void setOrgId(String orgId) {
        this.orgId = orgId;
    }

    public String getSourceId() {
        return sourceId;
    }

    public void setSourceId(String sourceId) {
        this.sourceId = sourceId;
    }

    public String getSourceFrom() {
        return sourceFrom;
    }

    public void setSourceFrom(String sourceFrom) {
        this.sourceFrom = sourceFrom;
    }

    public String getCrisisFlag() {
        return crisisFlag;
    }

    public void setCrisisFlag(String crisisFlag) {
        this.crisisFlag = crisisFlag;
    }

    public String getUnusualFlag() {
        return unusualFlag;
    }

    public void setUnusualFlag(String unusualFlag) {
        this.unusualFlag = unusualFlag;
    }

    public String getReportType() {
        return reportType;
    }

    public void setReportType(String reportType) {
        this.reportType = reportType;
    }

    public String getReportSource() {
        return reportSource;
    }

    public void setReportSource(String reportSource) {
        this.reportSource = reportSource;
    }

    public String getClinicNo() {
        return clinicNo;
    }

    public void setClinicNo(String clinicNo) {
        this.clinicNo = clinicNo;
    }

    @JsonIgnore
    @JsonGetter
    public InnerBean getOrg() {
        return org;
    }

    public void setOrg(InnerBean org) {
        this.org = org;
    }

    @XmlJavaTypeAdapter(DateTimeAdapter.class)
    public Date getCreateDt() {
        return createDt;
    }

    public void setCreateDt(Date createDt) {
        this.createDt = createDt;
    }

    public String getCrisisDesc() {
        return crisisDesc;
    }

    public void setCrisisDesc(String crisisDesc) {
        this.crisisDesc = crisisDesc;
    }

    @JsonIgnore
    @JsonGetter
    public InnerBean getDept() {
        return dept;
    }

    public void setDept(InnerBean dept) {
        this.dept = dept;
    }

    @XmlTransient
    public String getLocalDeptId() {
        return dept != null ? dept.getLocalCode() : null;
    }

    @JsonIgnore
    @JsonGetter
    public InnerBean getDoctor() {
        return doctor;
    }

    public void setDoctor(InnerBean doctor) {
        this.doctor = doctor;
    }

    @XmlTransient
    public String getDoctorId() {
        return doctor != null ? doctor.getText() : null;
    }

    @XmlTransient
    public String getLocalDoctorId(){
        return doctor != null ? doctor.getLocalCode() : null;
    }

    @XmlTransient
    public String getDoctorName() {
        return doctor != null ? doctor.getLocalText() : null;
    }

    @JsonIgnore
    @JsonGetter
    public InnerBean getRpOrg() {
        return rpOrg;
    }

    public void setRpOrg(InnerBean rpOrg) {
        this.rpOrg = rpOrg;
    }

    @XmlTransient
    public String getRpOrgId() {
        return rpOrg != null ? rpOrg.getText() : null;
    }

    @XmlTransient
    public String getRpOrgName() {
        return rpOrg != null ? rpOrg.getLocalText() : null;
    }

    @JsonIgnore
    @JsonGetter
    public InnerBean getRpDoctor() {
        return rpDoctor;
    }

    public void setRpDoctor(InnerBean rpDoctor) {
        this.rpDoctor = rpDoctor;
    }

    @XmlTransient
    public String getRpDoctorId() {
        return rpDoctor != null ? rpDoctor.getText() : null;
    }

    @XmlTransient
    public String getLocalRpDoctor(){
        return rpDoctor != null ? rpDoctor.getLocalCode() : null;
    }

    @XmlTransient
    public String getRpDoctorName() {
        return rpDoctor != null ? rpDoctor.getLocalText() : null;
    }

    @XmlJavaTypeAdapter(DateTimeAdapter.class)
    public Date getReportDt() {
        return reportDt;
    }

    public void setReportDt(Date reportDt) {
        this.reportDt = reportDt;
    }

    @JsonIgnore
    @JsonGetter
    public InnerBean getCheckDoctor() {
        return checkDoctor;
    }

    public void setCheckDoctor(InnerBean checkDoctor) {
        this.checkDoctor = checkDoctor;
    }

    @XmlTransient
    public String getCheckDoctorId(){
        return checkDoctor != null ? checkDoctor.getLocalText() : null;
    }

    @XmlTransient
    public String getLocalCheckDoctorId(){
        return checkDoctor != null ? checkDoctor.getLocalCode() : null;
    }

    @XmlTransient
    public String getCheckDoctorName(){
        return checkDoctor != null ? checkDoctor.getLocalText() : null;
    }

    @XmlJavaTypeAdapter(DateTimeAdapter.class)
    public Date getCheckDt() {
        return checkDt;
    }

    public void setCheckDt(Date checkDt) {
        this.checkDt = checkDt;
    }

    public String getComment() {
        return comment;
    }

    public void setComment(String comment) {
        this.comment = comment;
    }

    @XmlJavaTypeAdapter(DateTimeAdapter.class)
    public Date getBeginDate() {
        return beginDate;
    }

    public void setBeginDate(Date beginDate) {
        this.beginDate = beginDate;
    }

    @XmlJavaTypeAdapter(DateTimeAdapter.class)
    public Date getEndDate() {
        return endDate;
    }

    public void setEndDate(Date endDate) {
        this.endDate = endDate;
    }

    public String getDealFlag() {
        return dealFlag;
    }

    public void setDealFlag(String dealFlag) {
        this.dealFlag = dealFlag;
    }

    public String getNeedDealFlag() {
        return needDealFlag;
    }

    public void setNeedDealFlag(String needDealFlag) {
        this.needDealFlag = needDealFlag;
    }

    public String getDealMan() {
        return dealMan;
    }

    public void setDealMan(String dealMan) {
        this.dealMan = dealMan;
    }

    @XmlJavaTypeAdapter(DateTimeAdapter.class)
    public Date getDealDt() {
        return dealDt;
    }

    public void setDealDt(Date dealDt) {
        this.dealDt = dealDt;
    }

    public String getDealOpinion() {
        return dealOpinion;
    }

    public void setDealOpinion(String dealOpinion) {
        this.dealOpinion = dealOpinion;
    }

    public String getInpatientArea() {
        return inpatientArea;
    }

    public void setInpatientArea(String inpatientArea) {
        this.inpatientArea = inpatientArea;
    }
}
